package com.itheima.thread02;

public class Demo02 {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "执行到了" + i);
            }
        });
        t1.setName("某某某");
        t1.setDaemon(true);

        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName() + "执行到了" + i);
            }
        });
        t2.setName("备胎");
        t2.setDaemon(true);
        t1.start();
        t2.start();
        for (int i = 0; i < 10; i++) {
            Thread.sleep(100);
            System.out.println("main执行到了"+i);
        }


    }
}
